<template>
  <div class="contain-edit rent-detail">
    <div class="header">
      <p>查看详情</p>
      <el-button class="link" type="primary">
        <router-link to="/rentList" style="color: #fff;">返回</router-link>
      </el-button>
    </div>
    <div class="main">
      <div class="list">
        <div class="title">房源信息</div>
        <div class="flex-box-container">
          <div class="item flex">
            <div class="item-key">房客:</div>
            <div class="item-value">{{ info && info.renterName ? info.renterName : ''}}</div>
          </div>
          <div class="item flex">
            <div class="item-key">性别:</div>
            <div class="item-value">{{ info && info.renterSexText ? info.renterSexText : ''}}</div>
          </div>
        </div>
        <div class="flex-box-container">
          <div class="item flex">
            <div class="item-key">身份证号:</div>
            <div  class="item-value" >{{ info &&majorInfo ? majorInfo.idCardNo : ''}}</div>
          </div>
          <div class="item flex">
            <div class="item-key">联系方式:</div>
            <div  class="item-value" >{{ info && info.renterMobile  ? info.renterMobile  : ''}}</div>
          </div>
        </div>
        <div class="flex-box-container">
          <div class="item flex">
            <div class="item-key">紧急联系人:</div>
            <div  class="item-value" >{{ info && info.renterEmergencycontact ? info.renterEmergencycontact : ''}}</div>
          </div>
          <div class="item flex">
            <div class="item-key" style="white-space: nowrap">紧急联系人电话:</div>
            <div  class="item-value" >{{ info && info.renterEmergencymobile ? info.renterEmergencymobile : ''}}</div>
          </div>
        </div>
        <div class="item" style="min-height: 150px">
          <div class="item-key" style="height: 150px;line-height: 150px;white-space: nowrap">房客身份证正反面照片:</div>
          <div  class="item-value" style="height: 150px;line-height: 150px;">
            <div class="flex-box-container" style="margin-top: 35px;">
              <img :src="majorInfo && majorInfo.idcard1? majorInfo.idcard1 : ''" alt="" style="width: 120px;height:80px;margin-right: 10px;" >
               <img :src="majorInfo && majorInfo.idcard2 ? majorInfo.idcard2 : ''" alt="" style="width: 120px;height: 80px;margin-right: 10px;" >
            </div>
          </div>
        </div>
        <div class="flex-box-container">
          <div class="item flex">
              <div class="item-key">租客类型:</div>
              <div  class="item-value" >{{ info && info.rentalTypeText ? info.rentalTypeText : ''}}</div>
          </div>
          <div class="item flex">
            <div class="item-key">入住时间:</div>
            <div  class="item-value" >{{ info && info.rentalCheckin ? info.rentalCheckin : ''}}</div>
          </div>
        </div>
        <div v-for="(item,index) in partnerArr" :key="index">
          <div class="flex-box-container">
            <div class="item flex">
              <div class="item-key">同住人:</div>
              <div  class="item-value" >{{item.name }}</div>
            </div>
            <div class="item flex">
              <div class="item-key">同住人性别:</div>
              <div  class="item-value" >{{returnSex[item.sex] }}</div>
            </div>
          </div>
          <div class="flex-box-container">
            <div class="item flex">
              <div class="item-key">同住人联系方式:</div>
              <div  class="item-value" >{{ item.mobile}}</div>
            </div>
          </div>
          <div class="item" style="min-height: 150px">
            <div class="item-key" style="height: 150px;line-height: 150px;">房客身份证正反面照片:</div>
            <div  class="item-value" style="height: 150px;line-height: 150px;">
              <div class="flex-box-container" style="width: 80px;margin-top: 35px;">
                <img @click="imgClick(item.idcard1)" :src="item.idcard1? item.idcard1 : ''" alt="" style="width: 120px;height:80px;margin-right: 10px;" >
                <img @click="imgClick(item.idcard2)" :src="item.idcard2 ? item.idcard2 : ''" alt="" style="width: 120px;height:80px;margin-right: 10px;" >
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <el-dialog
      :visible.sync="dialogVisible"
      size="tiny">
        <img style="width: 100%" :src="imgUrl" alt="">
    </el-dialog>
  </div>
  </div>
</template>

<script>
  let CONSTANT = require('../../constant/constant.js');
  let common = require("../../common.js");

  export default {
    data() {
      return {
        id:'',
        info: {},
        identify:'',
        majorInfo:'',
        partnerArr:[],
        dialogVisible:false,
        imgUrl:'',
        returnSex:{
          'male':'男',
          'female':'女',
          'unknow':'未知'
        }
      }
    },
    created() {
      this.id  = this.$router.currentRoute.query.id;
      this.identify = sessionStorage.getItem("identify");
      this.getDetail(this.id);
    },
    methods: {
      imgClick(url){
          this.imgUrl = url;
          this.dialogVisible = true;
      },
      getDetail(id){
        let url = this.identify == 1 ? CONSTANT.URL.RENTAL.DETAIL : CONSTANT.URL.L_RENTAL.FINDETAIL;
       console.log(this.identify,url)
       let param = {
          id:id
        };
        common.requestAjax(url,{},param,(res)=>{
          this.loading = false;
          this.info = res.data.bussData;
          let arr = []
          if(this.info.rentalRenters&&this.info.rentalRenters.length){
            this.info.rentalRenters.map((item)=>{
              if(item.renterType == 'major'){
                this.majorInfo  = item
              }else if(item.renterType == 'partner'){
                arr.push(item)
              }
            })
            this.partnerArr = arr;
          }
        })
      },
    },
  }
</script>
<style lang="scss" scoped>
  .rent-detail{
    .item-key{
      width: 170px!important;
    }
  }
  .item-left {
    float: left;
    width: 120px;
    padding-left: 20px;
    padding-right: 10px;
    // height: 40px;
    line-height: 40px;
    text-align: right;
    border-right: 1px solid #dedede;
  }
  .item-right {
    // height: 40px;
    // line-height: 40px;
    padding-left: 20px;
    float: left;
  }
  .backage {
    height: auto;
    border: 1px solid #dedede;
    border-top: none;
  }
  .analyse{
    margin-left: 151px;
    height:530px;
    padding-top: 20px;
    display: flex;
  }
  .pic{
    width:330px;
    height:530px;
    // background-color:yellowgreen;
    display: inline-block;
    margin-right: 30px;
    padding-left: 20px;
    .avatar-info{
      .avatar{
        width:100px;
        height:100px;
        background-color:#626262;
        margin-top:50px;
        border-radius:50%;
        float:left;
        .avatar-img{
          width: 100%;
          height: 100%;
        }
      }
      .info{
        // float:left;
        // margin-top:50px;
        margin-left:10px;
        padding: 60px 20px;
      }
    }
  }
  .pic-font{
    border-left: 5px solid #999;
    width: 100px;
    height: 40px;
    line-height: 40px;
    // background-color: pink;
    // margin-left: 15px;
    margin-bottom: 15px;
    display: block;
  }
  .wins{
    display: inline-block;
    height: 350px;
    flex: 1;
  }
  .match{
    list-style:none;
    padding-left:20px;
    margin-top:20px;
    .match-item{
      width: 300px;
      height:50px;
      background-color: #eee;
      margin-bottom:30px;
    }
  }
  #chart{
    width:300px;
    height:300px;
  }
  .honor {
    float: left;
    width: 150px;
    height: 150px;
    margin-right: 20px;
    // background-color: yellow;
    .honor-img{
      width: 70px;
      height: 70px;
      padding: 30px 40px 0px 40px;
    }
    .honor-span{
      width: 40px;
      height: 20px;
      border: 1px solid #ccc;
      display: block;
      margin-left: 55px;
    }
    .honor-text{
      display: block;
      text-align: center;
      font-size: 14px;
    }
  }

</style>


